// index.js
import {OrderList} from "../../../api/index"

Page({
  data: {
    orderList:[],
    userName:''
  },
  
  async orderList(){
    let res = await OrderList({})
    console.log("订单列表",res)
    res.dataset.forEach(item => {
      item.year=item.realOrderTime.substr(0,4)
       item.yue=item.realOrderTime.substr(5,5) 
    });
    this.setData({
      orderList:res.dataset
    })
    
  },

  // 去订单详情
  toOrderDetail(event){
    let orderid=event.currentTarget.dataset.orderid
    wx.navigateTo({
      url: `../orderDetial/orderDetial?orderId=${orderid}`,
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.orderList()
    this.setData({
      userName:wx.getStorageSync('info').username
    })
  },
})
